from django.test import TestCase

from users.models import UserNode


'''class Neo4jUserRelTestCase(TestCase):
    def setUp(self) -> None:
        Alice = self.create_node(username='Alice')
        Bob = self.create_node(username='Bob')
        Charlie = self.create_node(username='Charlie')
        David = self.create_node(username='David')

        self.a_follow_b(Alice, Bob)
        self.a_follow_b(Alice, Charlie)
        self.a_follow_b(Alice, David)

        self.a_follow_b(Bob, Alice)
        self.a_follow_b(Bob, David)

    def test_relationship(self):
        """
        Alice follows Bob, Charlie, David.
        Bob follows Alice, David.

        Alice's fans are: Bob.
        Bob's fans are: Alice.
        Charlie's fans are: Alice.
        David's fans are: Alice, Bob.

        """
        alice = UserNode.nodes.get_or_none(username='Alice', user_id=1)
        bob = UserNode.nodes.get_or_none(username='Bob', user_id=2)
        charlie = UserNode.nodes.get_or_none(username='Charlie', user_id=3)
        david = UserNode.nodes.get_or_none(username='David', user_id=4)

        alice_follow_list = alice.follows.all()
        bob_follow_list = bob.follows.all()
        charlie_follow_list = charlie.follows.all()
        david_follow_list = david.follows.all()

        self.assertEqual(alice_follow_list.__len__(), 3)
        self.assertEqual(bob_follow_list.__len__(), 2)
        self.assertEqual(charlie_follow_list.__len__(), 0)
        self.assertEqual(david_follow_list.__len__(), 0)

        alice_fan_list = alice.fans.all()
        bob_fan_list = bob.fans.all()
        charlie_fan_list = charlie.fans.all()
        david_fan_list = david.fans.all()

        self.assertEqual(alice_fan_list.__len__(), 1)
        self.assertEqual(bob_fan_list.__len__(), 1)
        self.assertEqual(charlie_fan_list.__len__(), 1)
        self.assertEqual(david_fan_list.__len__(), 2)

    @staticmethod
    def a_follow_b(A: UserNode, B: UserNode) -> None:
        """
        A follow B. First add a FollowRel edge from A to B,
        then add a FanRel edge from B to A.
        """
        A.follows.connect(B)
        B.fans.connect(A)

    @staticmethod
    def create_node(username: str) -> UserNode:
        return UserNode(username=username).save()'''
